Skip to content

fix: increase LSP initialize timeout for JDTLS and KotlinLS#25649

Open
norbu35 wants to merge 3 commits intoanomalyco:devfrom
norbu35:fix/lsp-jdtls-initialize-timeout
Open

fix: increase LSP initialize timeout for JDTLS and KotlinLS#25649
norbu35 wants to merge 3 commits intoanomalyco:devfrom
norbu35:fix/lsp-jdtls-initialize-timeout

Conversation

@norbu35
Copy link
Copy Markdown

@norbu35 norbu35 commented May 3, 2026

Issue for this PR

Closes #23982

Type of change

  • Bug fix

What does this PR do?

JDTLS and KotlinLS are JVM-based language servers. During the LSP initialize handshake they run Gradle project sync and workspace indexing, which takes 60–180 seconds on real projects. The hardcoded 45 s timeout causes every lsp_diagnostics call to fail with LSP request timeout (method: initialize).

The fix adds an optional initializeTimeout field to the LSPServer.Handle interface so built-in servers can declare their timeout needs. The client uses it with input.server.initializeTimeout ?? INITIALIZE_TIMEOUT_MS, so the default 45 s is preserved for every other server. JDTLS and KotlinLS both set initializeTimeout: 180_000.

Changes:

  • packages/opencode/src/lsp/server.ts — add initializeTimeout?: number to Handle; set 180_000 for JDTLS and KotlinLS
  • packages/opencode/src/lsp/client.ts — use per-server timeout with 45 s fallback

No other servers are affected.

How did you verify your code works?

  • bun typecheck passes across all 19 packages
  • bun test test/lsp/ — 31 pass, 0 fail
  • bun test test/config/lsp.test.ts — 9 pass, 0 fail
  • The change is a single ?? fallback — if initializeTimeout is undefined (every server except JDTLS/KotlinLS), behavior is identical to before

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

JDTLS (Eclipse JDT Language Server) and KotlinLS are JVM-based
language servers that must perform Gradle project sync and workspace
indexing during LSP initialize. For real-world projects this routinely
takes 60-180 seconds, well above the default 45 s timeout.

Add an optional initializeTimeout field to the LSP server Handle
interface so built-in servers can declare their timeout needs. Use it
in the client with the existing 45 s constant as the default.

Set 180 s for JDTLS and KotlinLS, both of which run on the JVM and
trigger Gradle sync during initialization.

Closes anomalyco#23982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP initialize timeout too short for Java/Gradle projects (~15s vs ~114s needed)

1 participant